package com.itheima04;

import java.util.concurrent.Semaphore;

public class MyRunnable implements Runnable {
    private Semaphore semaphore = new Semaphore(2);


    @Override
    public void run() {
        try {
            semaphore.acquire();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("获得了通行证");
        System.out.println("回收了通行证");

        semaphore.release();
    }
}
